home *** CD-ROM | disk | FTP | other *** search
- // Author : Andy Earp(NetSupport Ltd)
- // File name : DelRegKey.scp
- // Date created : 17/08/00
- // Description :
-
- // Please run the script titled CreateRegKey.scp to see this script work successfully. This script has been written
- // as a example of how to delete Keys and there values and will delete the key and values create by the script
- // CreateRegKey.scp. If you choose not to run CreateRegKey.scp first then the script will create a temporary key
- // so that the script will complete error free. Please not that deleting vital keys from your machine can be very
- // destructive to your machine.
-
- Print "*************************************************************"
- Print " "
- Print " This script will delete the registry key created"
- Print " by the sample script Createregkey.scp. If the key "
- Print " does not exist on your local machine then it will"
- Print " temporarily create the key to delete."
- Wait (8)
-
- Dim Valuenames
-
- //Open the registry key created by CreateRegKey.scp
-
- Handle = RegOpenKey (HKEY_LOCAL_MACHINE, "SOFTWARE\NetSupportTestKey")
-
- //if the handle returned is invalid create a temporary key. This is deleted later.
-
- If !Handle then
- Print " "
- Print " ****************************************************************"
- Print " * The registry key was not found has it been created! *"
- Print " * A temporary key has been created for the script to *"
- Print " * complete error free *"
- Print " ****************************************************************"
- Handle = RegCreateKey (HKEY_LOCAL_MACHINE, "SOFTWARE\NetSupportTestKey")
- Wait(10)
- EndIf
-
- //This function enumerates all of the values within a specified registry key
- If !RegEnumValues (Handle, Valuenames) then
-
- ...
- Endif
-
- Print " "
- Print " If values exist in the registry they will be "
- Print " displayed and deleted from the Key."
- Wait (3)
-
- For Each Value in Valuenames
- Print " "
- Print " Value name: - ", Value, " has been deleted!" //Prints the name for each value in the key.
- RegDeleteValue (Handle, Value) //Deletes all the values found in the key.
- Wait(2)
- Next
-
- // It is important to always close a key when you have finished using it, if you do not close the key then when the scripts
- // finishes the key will be closed automatically.
-
- RegCloseKey(handle)
-
- //Opens the registry key.
- Handle = RegOpenKey (HKEY_LOCAL_MACHINE, "SOFTWARE\NetSupportTestKey")
-
- //Delete the key that was either opened or created.
- If Handle then
- Print " "
- Print " *************************************************************"
- Print " "
- Print " The below registry key has been deleted : "
- Wait (3)
- Print " "
- Print " HKEY_LOCAL_MACHINE\SOFTWARE\ "
- Print " NetSupportTestKey "
- Print " "
- Print " *************************************************************"
- Print " "
- RegDeleteKey( Handle, "")
- Wait (4)
- Else
- Print " "
- Print " Unable to create or open the registry key ! "
- Print " ************************************************** "
- Print " "
- Wait (4)
- Endif
-
- //Closes the Registry key.
- RegCloseKey(handle)
-
- Print "To edit or view the contents of this"
- Print "script right mouse button click"
- Print "on the Script icon and select Edit"
- Wait (5)
-
- //Copyright ⌐ 2000
-
-
-
-